package com.zby.big_event_zby.mapper;

import com.zby.big_event_zby.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @version 1.0
 * @auther ZBY
 */

@Mapper
public interface UserMapper {
    //根据用户名查询用户
    @Select("select * from user where username = #{username}")
    public User findByUsername(String username);
    //注册
    @Insert("insert into user (username,password,create_time,update_time) values (#{username},#{password},now(),now())")
    public void register(String username,String password);
    //更新用户信息
    @Update("update user set nickname = #{nickname},email = #{email},update_time = now() where id = #{id}")
    void update(User user);
    //更新头像
    @Update("update user set user_pic = #{avatarUrl},update_time = now() where id = #{id}")
    void updateAvatarUrl(String avatarUrl,Integer id);
     @Update("update user set password = #{password},update_time = now() where id = #{id}")
    void updatePwd(String password, Integer id);
}
